function plotter(track, Pitch, Radii, Index)
% function plotter(track, Pitch, Radii, Index)
% 
% Input:
%       track       - tracking data
%       Pitch       - pitch of pin cell
%       Radii       - radii of cell Radiiial zones
%       Index       - angular index ( from 1 to NumAzimuth )
% Output:
%       a plot
%

    % Plotting square
    Xa = [ 0.0; Pitch; Pitch; 0.0; 0.0 ];
    Ya = [ 0.0; 0.0; Pitch; Pitch; 0.0 ];
    plot (Xa ,Ya ,'k','LineWidth',4);
    hold on;
    
    % Plotting pins
%     for i = length(Radii):-1:1
%         t = 0:(2*pi/1000):(2*pi);
%         %plot (Pitch/2+Radii(i)*cos(t),Pitch/2+Radii(i)*sin(t),...
%         %    'k','LineWidth',3);
%         fill(Pitch/2+Radii(i)*cos(t),Pitch/2+Radii(i)*sin(t),col(i));        
%     end
    
    % Plotting tracks
    I = squeeze( track.Enter(Index,:,:) );
    F = squeeze( track.Exit(Index,:,:) );
    for k = 1:track.NumSpace
        plot ([I(k ,1) ;F(k ,1) ],[I(k ,2) ;F(k ,2) ],'Color',[rand rand rand],'LineWidth',2);
    end
    
    axis ([0 Pitch 0 Pitch])
    axis square ;
    grid on;
    hold off;
    
    xlabel(' x [cm] ')
    ylabel(' y [cm] ')
    title([' Pin Cell Tracking -- Angle Index ', num2str(Index)])
end

function color = col(g)
    % this function is a hard-coded color map for the different
    % flux groups.  I've accounted for up to 8 groups.
    % set(ur,'Color',[1 0.7 0.2],'LineWidth',2);
    switch g
        case 1
            color = [0.0 0.0 1.0]; % blue
        case 2
            color = [0.0 0.8 0.2]; % nice green
        case 3
            color = [1.0 0.0 0.0]; % red
        case 4
            color = [0.4 0.0 0.6]; % purple
        case 5
            color = [0.9 0.4 0.0]; % orange
        case 6
            color = [0.5 0.2 0.0]; % brown
        case 7
            color = [0.0 0.8 0.6]; % turquoise
        case 8
            color = [0.7 0.6 0.0]; % gold
        otherwise
            color = [rand rand rand]; % random
    end
end